package com.qubuyer.core.app

import android.content.ContentProvider
import android.content.ContentValues
import android.database.Cursor
import android.net.Uri
import com.qubuyer.core.utils.ActivityManager

/**
 * Author: linwg
 * Time: 2021/2/2 0002
 * Description:
 */
class ContextProvider : ContentProvider() {
    companion object {
        lateinit var applicationContext: BaseApplication
    }

    @Throws(IllegalStateException::class)
    override fun onCreate(): Boolean {
        if (context == null) {
            return false
        }
        if (context !is BaseApplication) {
            throw IllegalStateException("${this.context!!::class.java.simpleName} must extends BaseApplication")
        }
        applicationContext = context as BaseApplication
        ActivityManager.init(applicationContext)
        return true
    }

    override fun query(uri: Uri, projection: Array<out String>?, selection: String?, selectionArgs: Array<out String>?, sortOrder: String?): Cursor? {
        return null
    }

    override fun getType(uri: Uri): String? {
        return null
    }

    override fun insert(uri: Uri, values: ContentValues?): Uri? {
        return null
    }

    override fun delete(uri: Uri, selection: String?, selectionArgs: Array<out String>?): Int {
        return 0
    }

    override fun update(uri: Uri, values: ContentValues?, selection: String?, selectionArgs: Array<out String>?): Int {
        return 0
    }
}